﻿//-------------------------------------------------------------------
//	Copyright (c) 2010-2014  Zhirnov Andrey
//	This file is part of the "UX Standard Lib" project.
//	See copyright notice in "UX_STL_Core.h".
//-------------------------------------------------------------------

#ifndef _UXS_PLATFORMS_H
#define _UXS_PLATFORMS_H

#pragma once

//------------------------------- OS ------------------------------//

// Android platform //
#if !defined( PLATFORM_NAME ) && ( defined( ANDROID ) || defined( __ANDROID__ ) )
#	define PLATFORM_ANDROID			1
#	define PLATFORM_NAME			"Android"
#	define PLATFORM_32BIT			1
#	define PLATFORM_TYPE_MOBILE		1
#	define PLATFORM_BASE_POSIX		1
#endif


// Windows CE platform //
#if !defined( PLATFORM_NAME ) && defined( _WIN32_WCE )
#	define PLATFORM_WINDOWS_CE		1
#	define PLATFORM_NAME			"Windows CE"
#	define PLATFORM_TYPE_MOBILE		1
#	define PLATFORM_BASE_WINDOWS	1
#endif


// Windows platform //
#if !defined( PLATFORM_NAME ) && ( defined( _WIN32 ) || defined( _WIN64 ) || \
	defined( WIN32 ) || defined( WIN64 ) || defined( __CYGWIN__ ) || defined( __MINGW32__ ) )
#	define PLATFORM_WINDOWS			1
#	define PLATFORM_NAME			"Windows"
#	define PLATFORM_TYPE_DESCTOP	1
#	define PLATFORM_BASE_WINDOWS	1
#endif


// OSX platform //
#if !defined( PLATFORM_NAME ) && ( defined( __APPLE__ ) || defined( MACOSX ) )
# include "AvailabilityMacros.h"
# include "TargetConditionals.h"
# if defined( TARGET_OS_IPHONE )
#	define PLATFORM_IPHONE			1
#	define PLATFORM_NAME			"iPhone OS"
#	define PLATFORM_TYPE_MOBILE		1
# else
#	define PLATFORM_MACOSX			1
#	define PLATFORM_NAME			"Mac OS X"
#	define PLATFORM_TYPE_DESCTOP	1
# endif
#	define PLATFORM_BASE_POSIX		1
#endif


// Linux platform //
#if !defined( PLATFORM_NAME ) && defined( __linux__ )
#	define PLATFORM_LINUX			1
#	define PLATFORM_NAME			"Linux"
#	define PLATFORM_TYPE_DESCTOP	1
#	define PLATFORM_BASE_POSIX		1
#endif


// Free BSD platform //
#if !defined( PLATFORM_NAME ) && (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__))
#	define PLATFORM_FREEBSD			1
#	define PLATFORM_NAME			"FreeBSD"
#	define PLATFORM_TYPE_DESCTOP	1
#	define PLATFORM_BASE_POSIX		1	// ???
#endif


// 16, 32 or 64 bit platform
#if !defined( PLATFORM_16BIT ) || !defined( PLATFORM_32BIT ) || !defined( PLATFORM_64BIT )
# if defined( _LP64 ) || defined( _WIN64 ) || defined( _M_X64 )
#	define PLATFORM_64BIT	1
# else
#	define PLATFORM_32BIT	1
# endif
#endif

#if !defined( PLATFORM_BITS )  || !defined( PLATFORM_BITS_NAME )
#	undef PLATFORM_BITS
#	undef PLATFORM_BITS_NAME

# ifdef PLATFORM_16BIT
#	define PLATFORM_BITS		16
#	define PLATFORM_BITS_NAME	"16"
# endif

# ifdef PLATFORM_32BIT
#	define PLATFORM_BITS		32
#	define PLATFORM_BITS_NAME	"32"
# endif

# ifdef PLATFORM_64BIT
#	define PLATFORM_BITS		64
#	define PLATFORM_BITS_NAME	"64"
# endif

# ifdef PLATFORM_128BIT
#	define PLATFORM_BITS		128
#	define PLATFORM_BITS_NAME	"128"
# endif
#endif


// Unknown
#ifndef PLATFORM_NAME
#	error Unknown platform
#endif

#ifndef PLATFORM_BITS_NAME
#	error Unknown platform bits
#endif

#if !defined( PLATFORM_TYPE_DESCTOP ) && !defined( PLATFORM_TYPE_MOBILE )
#	error Unknown platform type
#endif



//-------------------------- Compiler -----------------------------//

// Microsoft Visual C++
#ifdef _MSC_VER
#	define COMPILER_MSVC		1
#	define COMPILER_NAME		"MSVC"
#	include "CompilerMSVC.h"
#endif


// GNU Compiler Collection
#ifdef __GNUC__
#	define COMPILER_GCC			1
#	define COMPILER_NAME		"GCC"
#	include "CompilerGCC.h"
#endif


// TODO: support compilers

// Intel C Compiler
#ifdef __INTEL_COMPILER
#	define COMPILER_INTEL		1
#	define COMPILER_NAME		"ICC"
#endif


// Borland
#ifdef __BORLANDC__
#	define COMPILER_BORLAND		1
#	define COMPILER_NAME		"Borland"
#endif


// Clang
#ifdef __clang__
#	define COMPILER_CLANG		1
#	define COMPILER_NAME		"Clang"
#endif


// Unknown
#ifndef COMPILER_NAME
#	error Unknown compiler
#endif


//------------------------- Language ------------------------------//

#ifndef __cplusplus
#	error Only C++ language are supported
#endif 


//-------------------------------------------------------------------

#endif	// _UXS_PLATFORMS_H